#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=100000;

int max(int a, int b) {
  return a>b ? a : b;
}

class Ele {
public:
  int v, id;

  static bool cmp(Ele &a, Ele &b) {
    return a.v<b.v;
  }
};

class Link {
	public:
		int last[maxn+1], next[maxn+1];

		int del(int o) {
			next[last[o]] = next[o];
			last[next[o]] = last[o];
			return last[o];
		}
};

int main() {
  freopen("snowboots2.in", "r", stdin);
  freopen("snowboots2.out", "w", stdout);

  static Ele bricks[maxn+1], boots[maxn+1];
  static int d[maxn+1], ans[maxn+1];
  int n, b;
  scanf("%d %d", &n, &b);
  for (int i=1; i<=n; i++) {
    scanf("%d", &bricks[i].v);
    bricks[i].id = i;
  }
  sort(bricks+1, bricks+n+1, Ele::cmp);

  for (int i=1; i<=b; i++) {
    scanf("%d %d", &boots[i].v, d+i);
    boots[i].id = i;
  }
  sort(boots+1, boots+b+1, Ele::cmp);

	static Link link;
	for (int i=1; i<=n; i++) {
		link.last[i] = i-1;
		link.next[i] = i+1;
	}
	int maxd=1;
  for (int i=b, j=n; i>0; i--) {
		for (; j>0 && bricks[j].v>boots[i].v; j--) {
			int t=link.del(bricks[j].id);
			maxd = max(maxd, link.next[t]-t);
		}
    ans[boots[i].id] =  maxd<=d[boots[i].id];
  }

  for (int i=1; i<=b; i++) {
    printf("%d\n", ans[i]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
